home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _rawgetc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.1 KB  |  78 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef PDCDEBUG
  5. char *rcsid__rawgetc = "$Header: C:\CURSES\private\RCS\_rawgetc.c 2.1 1993/06/18 20:22:35 MH Rel MH $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_rawgetch()    - Returns the next uninterpreted character (if available).
  14.  
  15.   PDCurses Description:
  16.      Gets a character without any interpretation at all and returns
  17.      it. If keypad mode is active for the designated window,
  18.      function key translation will be performed.  Otherwise,
  19.      function keys are ignored.  If nodelay mode is active in the
  20.      window, then PDC_rawgetch() returns -1 if no character is
  21.      available.
  22.  
  23.      WARNING:  It is unknown whether the FUNCTION key translation
  24.            is performed at this level. --Frotz 911130 BUG
  25.  
  26.   PDCurses Return Value:
  27.      This function returns OK on success and ERR on error.
  28.  
  29.   PDCurses Errors:
  30.      No errors are defined for this function.
  31.  
  32.   Portability:
  33.      PDCurses    int    PDC_rawgetch( void );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_rawgetch(void)
  38. {
  39. extern    int    c_pindex;            /* putter index */
  40. extern    int    c_gindex;            /* getter index */
  41. extern    int    c_ungind;            /* wungetch() push index */
  42. extern    chtype    c_ungch[NUNGETCH];        /* array of ungotten chars */
  43. extern    WINDOW*    _getch_win_;
  44. /* extern    WINDOW*    w;*/   /* w defined in wgetch() as static - _getch_win_ */
  45.                         /* is the same window - all references to w changed*/
  46.                         /* to _getch_win_ - marked with @@ */
  47.  
  48.     signed    c;
  49.     signed    oldc;
  50.  
  51. #ifdef PDCDEBUG
  52.     if (trace_on) PDC_debug("PDC_rawgetch() - called\n");
  53. #endif
  54.  
  55.     if (_getch_win_ == (WINDOW *)NULL)   /* @@ */
  56.         return( -1 );
  57.  
  58. #ifdef UNIX
  59.     c = getchar();
  60.     return(c);
  61. #else
  62.     while (1)        /* loop to get valid char */
  63.     {
  64.         c = PDC_get_bios_key();
  65.         oldc = c;
  66.         /*
  67.          * Return the key if it is not a special key.
  68.          */
  69.         if ((c = PDC_validchar(c)) >= 0)
  70.         {        /* get & check next char */
  71.             return( c );
  72.         }
  73.         if (_getch_win_->_use_keypad)
  74.             return( oldc );
  75.     }
  76. #endif
  77. }
  78.